#include<stdio.h>

char change(char c, int n)
{
    char key=1;
    key<<=n;
    if(key&c)  c=c&~key;
    else       c=c|key;
    return c;
}

void crypto(char *s,int key)
{
    while(*s){
        *s=change(*s,key);
        s++;
    }
}

int main()
{
    char s[200];
    char key;
    gets(s);
    scanf("%d",&key);
    crypto(s,key);
    printf("JiaMi:");
    puts(s);
    crypto(s,key);
    printf("JieMi:");
    puts(s);
}